<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <title>登录</title>

    <link rel="stylesheet" href="{{ asset('admin/libs/layui/css/layui.css') }}"/>
    <link rel="stylesheet" href="{{ asset('admin/css/login.css ')}}"/>
    <link rel="stylesheet" href="{{ asset('admin/module/admin.css?v=316 ')}}"/>

    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    {{--<script>--}}
        {{--if (window != top) {--}}
            {{--top.location.replace(location.href);--}}
        {{--}--}}
    {{--</script>--}}
</head>
<body>


<div class="login-wrapper">
    <div class="login-header">
        <img src="https://www.php.cn/static/images/logo.png"> 后台开发框架
    </div>
    <div class="login-body">
        <div class="layui-card">
            <div class="layui-card-header">
                <i class="layui-icon layui-icon-engine"></i>&nbsp;&nbsp;用户登录
            </div>

            <form class="layui-card-body layui-form layui-form-pane">

                <div class="layui-form-item">
                    <label class="layui-form-label"><i class="layui-icon layui-icon-username"></i></label>
                    <div class="layui-input-block">
                        <input name="username" type="text" placeholder="账号" class="layui-input"
                               lay-verType="tips" lay-verify="required" required/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><i class="layui-icon layui-icon-password"></i></label>
                    <div class="layui-input-block">
                        <input name="password" type="password" placeholder="密码" class="layui-input"
                               lay-verType="tips" lay-verify="required" required/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><i class="layui-icon layui-icon-vercode"></i></label>
                    <div class="layui-input-block">
                        <div class="layui-row inline-block">
                            <div class="layui-col-xs7">
                                <input name="captcha" type="text" placeholder="验证码" class="layui-input"
                                       autocomplete="off" lay-verType="tips" lay-verify="required" required/>
                            </div>
                            <div class="layui-col-xs5" style="padding-left: 6px;">
                                <img class="login-captcha" src="{{captcha_src()}}" style="cursor: pointer"
                                     onclick="this.src='{{captcha_src()}}'+Math.random()">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <a href="javascript:;" class="layui-link">帐号注册</a>
                    <a href="javascript:;" class="layui-link pull-right">忘记密码？</a>
                </div>
                <div class="layui-form-item">
                    <button lay-filter="login-submit" type="button"  lay-submit class="layui-btn layui-btn-fluid" >登 录</button>
                </div>
                <div class="layui-form-item login-other">
                    <label>第三方登录</label>
                    <a href="javascript:;"><i class="layui-icon layui-icon-login-qq"></i></a>
                    <a href="javascript:;"><i class="layui-icon layui-icon-login-wechat"></i></a>
                    <a href="javascript:;"><i class="layui-icon layui-icon-login-weibo"></i></a>
                </div>
            </form>
        </div>
    </div>




 </div>

 <!-- js部分 -->
 <script type="text/javascript" src="{{ asset('/admin/libs/layui/layui.js')}} "></script>
 <script type="text/javascript" src="{{ asset('/admin/js/common.js')}} "></script>
 <script>
     layui.use(['layer', 'form'], function () {
         var $ = layui.jquery;
         var layer = layui.layer;
         var form = layui.form;

         // 表单提交
         form.on('submit(login-submit)', function (obj) {
             console.log(obj.field);
             $.ajax({
                 url:"/admin/check",
                 type:'post',
                 data: obj.field,
                 dataType: 'json',
                 headers: {
                     'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                 },
                 success:function(res){
                     if(res.code==200){
                         console.log(res);
                         layer.msg('登录成功', {icon: 1, time: 1500}, function () {
                             location.href = '/admin/index';
                         });
                         return false;
                     }else {
                         layer.msg(res.msg, {icon: 2, time: 1500}, );
                     }
                 }
             });

         });

         // 图形验证码
         // $('.login-captcha').click(function () {
         //     this.src = this.src + '?t=' + (new Date).getTime();
         // });
     });
 </script>
 </body>
 </html>